function AllReady() {
    var mstform = Ext.getCmp("CntM7"); //获取容器
    var tabPanel = Ext.getCmp("tabPanel"); // 获取当前所在 tab 页
    var dgrid = Ext.getCmp("CntD7");
    var dstore = dgrid.store;
    var PhidYsfl = mstform.queryById("PhidYsfl");
    var PhidPc = mstform.getItem("PhidPc");
    var user_yztj_no = mstform.getItem("user_yztj_no");
    var user_djfa_no = mstform.getItem("user_djfa_no");
  
    var user_is_yztj = mstform.getItem("user_is_yztj");
    var toolbar = Ext.getCmp("toolbar");
    toolbar.get("imp").setText("引用采购/备品备件申请");
    toolbar.get("imp_push").setText("下推要货单");
  
    ////////////////////////////////////////////////////////////--toolbar--////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////--toolbar--////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////--toolbar--////////////////////////////////////////////////////////////
    // 新增“推送上上签”按钮
    var pushButton = toolbar.add({
      xtype: "button",
      text: "推送上上签",
      id: "pushBtn",
      iconCls: "icon-New",
      handler: function () {
        // 按钮点击后执行的逻辑，发送 AJAX 请求
        var phid = mstform.getItem("Phid").getValue(); // 假设 phid 存在于表单中
        var asrTable = mstform.getItem("asrTable").getValue(); // 假设 asrTable 存在于表单中
  
        // 拼接查询参数
        var url = "http://nginx.clouddev.hisense.com/sd/Signed/push/uploadContract" + "?phid=" + phid + "&asrTable=" + asrTable;
  
        // 使用 GET 请求
        Ext.Ajax.request({
          url: url,
          method: "POST",
          success: function (response) {
            var res = Ext.decode(response.responseText);
            if (res.success) {
              Ext.Msg.alert("提示", "推送成功");
            } else {
              Ext.Msg.alert("错误", "推送失败");
            }
          },
          failure: function () {
            Ext.Msg.alert("错误", "请求失败，请稍后再试");
          },
        });
      },
    });
    if (otype == "add") {
      if (mstform.getItem("user_lj_amt").getValue()) {
      } else {
        mstform.getItem("user_lj_amt").setValue(0);
      }
      if (mstform.getItem("user_unpaid_amt").getValue()) {
      } else {
        mstform.getItem("user_unpaid_amt").setValue(0);
      }
      if (mstform.getItem("user_payable_amt").getValue()) {
      } else {
        mstform.getItem("user_payable_amt").setValue(0);
      }
      addContractTerms();
    }
    if (otype == "add") {
      if (mstform.getItem("PhidPc").getValue()) {
        getPtInfoByPhid();
      }
      PhidYsfl.setValue("14");
      BatchBindCombox([PhidYsfl]);
    }
  
    user_is_yztj.addListener("change", function (args) {
      console.log("args.value??XX", args.value);
    });
    mstform.getItem("PhidPc").addListener("helpselected", function (args) {
      console.log("PhidPchelpselected", args);
      getPtInfoByPhid();
    });
    allSameValue();
    mstform.getItem("PhidSenComp").addListener("helpselected", function (args) {
      console.log("dgrid.getView().refresh()");
      dstore.each(function (record) {
        console.log(mstform.getItem("PhidSenComp").getValue(), "PhidSenComp");
        console.log(mstform.getItem("user_sjbm").getValue(), "user_sjbm");
        async function asfun() {
          try {
            const res1 = await new Promise((resolve, reject) => {
              execServer("autoSelectType", { id: record.data.PhidItemId }, function (res) {
                resolve(res);
              });
            });
            const resWzxlData = JSON.parse(res1.data)[0].extendObjects;
            const res2 = await new Promise((resolve, reject) => {
              execServer("getAutoType", { phid: resWzxlData.phid_resbs }, function (res) {
                resolve(res);
              });
            });
            const datas = JSON.parse(res2.data)[0].extendObjects;
  
            record.set("user_item_xl_name", datas.name);
            record.set("user_item_xl", resWzxlData.phid_resbs);
            record.set("user_item_zl_name", datas.fname);
            record.set("user_item_zl", datas.f_phid);
            record.set("user_item_dl_name", datas.gname);
            record.set("user_item_dl", datas.g_phid);
            if (!record.data.PhidItemData) return; //判断是否为空
            execServer("GETitemzq", { phid: record.data.PhidItemData }, function (res) {
              try {
                const datas = JSON.parse(res.data);
                let DHZQ = datas[0].extendObjects.pur_lead;
                const newDate = addDaysToDate(mstform.getItem("BillDt").value, DHZQ);
                record.set("user_delivery_cycle", DHZQ);
                record.set("user_exp_arrival_date", newDate);
              } catch (error) {
                Ext.Msg.alert("服务器错误，请联系管理员");
              }
            });
          } catch (error) {
            console.error(error);
          }
        }
        if (!record.data.PhidItemId) return;
        record.set("ItemName", record.data.PhidItemId_EXName);
        record.set("ItemNo", record.data.ItemDataNo);
        console.log(mstform.getItem("PhidSenComp").getValue(), 'mstform.getItem("PhidSenComp").getValue()');
        if (mstform.getItem("PhidSenComp").getValue() && mstform.getItem("user_sjbm").getValue() && record.data.PhidItemId) {
          getBeforePrice(record);
        }
        asfun();
        dgrid.getView().refresh();
      });
    });
    user_yztj_no.on("beforetriggerclick", function (eOp, ignoreBeforeEvent) {
      console.log('stform.getItem("user_sjbm").getValue()', mstform.getItem("user_sjbm").getValue());
      if (Ext.isEmpty(PhidPc.getValue())) {
        Ext.Msg.alert("提示", "请先选择工程项目！"); //未选择提示：请先选择项目！
        return false;
      }
      user_yztj_no.setOutFilter({
        u_sj_no: mstform.getItem("user_sjbm").getValue(),
        u_sj_name: mstform.getItem("user_sjmc").getValue(),
      });
    });
    user_djfa_no.on("beforetriggerclick", function (eOp, ignoreBeforeEvent) {
      if (Ext.isEmpty(PhidPc.getValue())) {
        Ext.Msg.alert("提示", "请先选择工程项目！"); //未选择提示：请先选择项目！
        return false;
      }
  
      user_djfa_no.setOutFilter({
        u_sjh: mstform.getItem("user_sjbm").getValue(),
      });
    });
    user_djfa_no.addListener("helpselected", function (args) {
      console.log(args, "user_djfa_noxx");
      console.log(args.data?.u_zbfs, "user_djfa_noxx");
  
      mstform.getItem("user_djfs").setValue(args.data?.u_zbfs); //付款方式
      BatchBindCombox([mstform.getItem("user_djfs")]);
      execServer(
        "getfkfs",
        {
          no: `'${args?.data?.bill_no}'`,
        },
        function (res) {
          try {
            const datas = JSON.parse(res.data)[0].extendObjects;
            mstform.getItem("user_fkfs").setValue(datas?.user_fkfs); //付款方式
          } catch (error) {
            mstform.getItem("user_fkfs").setValue(""); //付款方式
          }
        }
      );
    });
    // 监听区域中心
    mstform.getItem("user_regional_center").addListener("change", function (args) {
      mstform.getItem("user_regional_center").setValue(args.value); //区域中心
      BatchBindCombox([mstform.getItem("user_regional_center")]);
    });
    // 监听采购组织
    mstform.getItem("user_pur_org").addListener("change", function (args) {
      BatchBindCombox([mstform.getItem("user_pur_org")]);
    });
    // 监听采购合同税率
    // mstform.getItem("user_taxrate").addListener("change", function (args) {
    //   console.log(args);
    //   // mstform.getValues().user_taxrate;
    //   console.log(mstform.getValues().user_taxrate);
    //   dstore.each(function (item) {
    //     item.set("TaxRate", mstform.getValues().user_taxrate);
    //   });
    // });
    // 监听业主推荐单号
    mstform.getItem("user_yztj_no").addListener("change", function (args) {
      if (args.value == 1) {
        execServer(
          "GETyztj",
          {
            pc: mstform.getItem("pc").getValue(),
          },
          function (res) {
            const datas = JSON.parse(res.data)[0].extendObjects;
          }
        );
      }
    });
  
    mstform.getItem("PhidSenComp").addListener("change", function (args) {
      if (!mstform.getItem("PhidSenComp").getValue()) return;
      try {
        execServer(
          "GETlinkman",
          {
            ent: mstform.getItem("PhidSenComp").getValue(),
          },
          function (res) {
            console.log(res,'11111111');
            const datas = JSON.parse(res.data)[0].extendObjects;
            // 植物user_duties  mainrole
            mstform.getItem("user_duties").setValue(datas.mainrole); //职务
            mstform.getItem("user_contact_information").setValue(datas.handset); //联系方式
            mstform.getItem("user_payee").setValue(datas.phid); //收款方
            BatchBindCombox([mstform.getItem("user_payee")]);
            mstform.getItem("user_bank_account").setValue(datas.accountno); //银行卡
            mstform.getItem("user_ghf_contacts").setValue(datas.cname); //供方联系人
            mstform.getItem("user_mailbox").setValue(datas.email); //供方联系人
            console.log("业主推荐", datas);
          }
        );
        execServer(
          "getEnterpriseInfoByPhid",
          {
            phid: mstform.getItem("PhidSenComp").getValue(),
          },
          function (res) {
            console.log(res,'2222222');
            
            const datas = JSON.parse(res.data)[0].extendObjects; // 植物user_duties  mainrole
            mstform.getItem("user_khbank").setValue(datas.taxbankname); //开户银行
            mstform.getItem("user_supply_address").setValue(datas.taxaddress); //注册地址
            mstform.getItem("user_bankno").setValue(datas.bankno); //开户银行行号
            // mstform.getItem("user_sh").setValue(datas.); //税号
            // mstform.getItem("user_yzbm").setValue(datas.); //税号
            console.log("业主推荐", datas);
          }
        );
      } catch (error) {
        console.log("未查找到联系人");
      }
    });
  
    //申请部门//申请人111//采购组织
    if (otype == "add" || otype == "copy" || otype == "edit") {
      execServer("GETuserdept", { phid: $appinfo.userID }, function (res) {
        const datas = JSON.parse(res.data)[0].extendObjects;
        if (res.count > 0) {
          mstform.getItem("user_apply_dept").setValue(datas.dept_id); //申请部门
          mstform.getItem("PhidCm").setValue(datas.hrid); //申请人111
          BatchBindCombox([mstform.getItem("user_apply_dept")]);
          BatchBindCombox([mstform.getItem("PhidCm")]);
        }
      });
      if ($appinfo.ocode) {
        execServer("GETORG", { code: $appinfo.ocode }, function (res) {
          const datas = JSON.parse(res.data)[0].extendObjects;
          if (res.count > 0) {
            mstform.getItem("user_pur_org").setValue("" + datas.phid); //采购组织
          }
        });
      }
    }
  
    /**
     *@function:带出项目信息
     */
    function getPtInfoByPhid() {
      console.log("带出项目信息", "??");
      if (mstform.getItem("PhidPc").getValue()) {
        execServer("getPtInfoByPhid", { phid: mstform.getItem("PhidPc").getValue() }, function (res) {
          const datas = JSON.parse(res.data)[0].extendObjects;
  
          mstform.getItem("user_regional_center").setValue(datas.regional_center_phid); //区域中心
          mstform.getItem("PhidPm").setValue(datas.project_manager_phid); //项目经理
          mstform.getItem("SenEmp").setValue(datas.user_sqgw_phid); //部门商务
          mstform.getItem("user_sjbm").setValue(datas.user_sjbm); //部门商务
          BatchBindCombox([mstform.getItem("user_regional_center")]);
          BatchBindCombox([mstform.getItem("user_project_manager")]);
          BatchBindCombox([mstform.getItem("SenEmp")]);
          BatchBindCombox([mstform.getItem("PhidPm")]);
        });
  
        execServer("projectSjbm", { phid: mstform.getItem("PhidPc").getValue() }, async function (res) {
          const datas = JSON.parse(res.data)[0].extendObjects;
          mstform.getItem("user_sjbm").setValue(datas.user_sjbm); //
          mstform.getItem("user_sjmc").setValue(datas.user_sjmc); //
          BatchBindCombox([mstform.getItem("user_sjbm")]);
          BatchBindCombox([mstform.getItem("user_sjmc")]);
  
          await execServer("isYzPush", { sjno: "'" + datas.user_sjbm + "'" }, function (res1) {
            console.log(res1.data, "isYzPush");
            if (res1.data.length > 0) {
              mstform.getItem("user_is_yztj").setValue("1");
            } else {
              mstform.getItem("user_is_yztj").setValue("0");
            }
            BatchBindCombox([mstform.getItem("user_is_yztj")]);
          });
        });
        dstore.each(function (record) {
          console.log(mstform.getItem("PhidSenComp").getValue(), "PhidSenComp");
          console.log(mstform.getItem("user_sjbm").getValue(), "user_sjbm");
          async function asfun() {
            try {
              const res1 = await new Promise((resolve, reject) => {
                execServer("autoSelectType", { id: record.data.PhidItemId }, function (res) {
                  resolve(res);
                });
              });
              const resWzxlData = JSON.parse(res1.data)[0].extendObjects;
              const res2 = await new Promise((resolve, reject) => {
                execServer("getAutoType", { phid: resWzxlData.phid_resbs }, function (res) {
                  resolve(res);
                });
              });
              const datas = JSON.parse(res2.data)[0].extendObjects;
  
              record.set("user_item_xl_name", datas.name);
              record.set("user_item_xl", resWzxlData.phid_resbs);
              record.set("user_item_zl_name", datas.fname);
              record.set("user_item_zl", datas.f_phid);
              record.set("user_item_dl_name", datas.gname);
              record.set("user_item_dl", datas.g_phid);
              if (!record.data.PhidItemData) return; //判断是否为空
              execServer("GETitemzq", { phid: record.data.PhidItemData }, function (res) {
                try {
                  const datas = JSON.parse(res.data);
                  let DHZQ = datas[0].extendObjects.pur_lead;
                  const newDate = addDaysToDate(mstform.getItem("BillDt").value, DHZQ);
                  record.set("user_delivery_cycle", DHZQ);
                  record.set("user_exp_arrival_date", newDate);
                } catch (error) {
                  Ext.Msg.alert("服务器错误，请联系管理员");
                }
              });
            } catch (error) {
              console.error(error);
            }
          }
          if (!record.data.PhidItemId) return;
          record.set("ItemName", record.data.PhidItemId_EXName);
          record.set("ItemNo", record.data.ItemDataNo);
          console.log(mstform.getItem("PhidSenComp").getValue(), 'mstform.getItem("PhidSenComp").getValue()');
          if (mstform.getItem("PhidSenComp").getValue() && mstform.getItem("user_sjbm").getValue() && record.data.PhidItemId) {
            getBeforePrice(record);
          }
  
          asfun();
        });
      }
    }
    dgrid.addListener("edit", function (editor, e) {
      var record = e.record;
      if (e.originalValue == e.value) {
        return;
      }
      record.set("user_yhsyl",record.get("Qty"))
      var data = dgrid.getSelectionModel().getSelection();
      console.log(data[0]);
      console.log(data[0].data.user_review_prc);
      console.log(e.value);
  
      if (e.value > data[0].data.user_review_prc) {
        record.set("PrcFc", 0);
        Ext.Msg.alert("提示", "合同未税单价不能大于评审未税单价！");
      }else {
        SetTotal();
  
      }
    });
  
    function tarChange(params) {
      Ext.each(dstore.getRange(), function (records, index) {
          console.log(records.store.data.items, "records");
          const row = records.store.data.items;
          Ext.each(row, function (r) {
              const current = r.data.user_review_prc; // 评审价格
              const nowValue = r.data.PrcFc;          // 当前价格
              
              // 添加核心判断逻辑
              if (nowValue > current) {
                  // 弹出提示（ExtJS标准方式）
                  Ext.Msg.alert("警告", "当前价格超过评审价格，自动重置为0");
                  
                  // 修改价格字段（通过set方法保证数据更新）
                  r.set('PrcFc', 0); 
              }
  
              console.log(current, nowValue);
          });
      });
  }
    dgrid.addListener("edit", function (editor, e) {
      var record = e.record;
      var taxRates = []; // 存储所有税率值的数组
      var allSameValue; // 存储统一税率值（如果存在）
      Ext.each(dstore.getRange(), function (records, index) {
        console.log(records.store.data.items, "records");
        const row = records.store.data.items;
        Ext.each(row, function (r) {
          const currentTaxRate = r.data.OriTaxRate; // 获取当前行的税率
          taxRates.push(currentTaxRate); // 存入数组
        });
        const isAllSame = taxRates.length > 0 && taxRates.every((rate) => rate === taxRates[0]);
  
        // 如果全部相同，取出统一值
        if (isAllSame) {
          allSameValue = taxRates[0]; // 保存相同的税率值
          mstform.getItem("user_taxrate").setValue(allSameValue);
          console.log("统一税率值:", allSameValue);
          // 在此执行你的统一逻辑（例如更新全局变量或界面）
        } else {
          mstform.getItem("user_taxrate").setValue("");
          console.log("税率不一致");
          // 在此执行不一致逻辑
        }
      });
    });
  
    function allSameValue(params) {
      var taxRates = []; // 存储所有税率值的数组
      var allSameValue; // 存储统一税率值（如果存在）
      Ext.each(dstore.getRange(), function (records, index) {
        console.log(records.store.data.items, "records");
        const row = records.store.data.items;
        Ext.each(row, function (r) {
          const currentTaxRate = r.data.OriTaxRate; // 获取当前行的税率
          taxRates.push(currentTaxRate); // 存入数组
        });
        const isAllSame = taxRates.length > 0 && taxRates.every((rate) => rate === taxRates[0]);
  
        // 如果全部相同，取出统一值
        if (isAllSame) {
          allSameValue = taxRates[0]; // 保存相同的税率值
          mstform.getItem("user_taxrate").setValue(allSameValue);
          console.log("统一税率值:", allSameValue);
          // 在此执行你的统一逻辑（例如更新全局变量或界面）
        } else {
          mstform.getItem("user_taxrate").setValue("");
          console.log("税率不一致");
          // 在此执行不一致逻辑
        }
      });
    }
  
    //监听 物料名称
    dgrid
      .getColumn("PhidItemId_EXName")
      .getEditor()
      .addListener("helpselected", function (record) {
        var data = dgrid.getSelectionModel().getSelection();
        data[0].set("ItemName", data[0].data.PhidItemId_EXName);
        data[0].set("ItemNo", data[0].data.ItemDataNo);
        execServer("autoSelectType", { id: record.data.PhId }, function (res) {
          let resWzxlData = JSON.parse(res.data)[0].extendObjects;
          if (res.status == "success") {
            execServer("getAutoType", { phid: resWzxlData.phid_resbs }, function (res) {
              const datas = JSON.parse(res.data)[0].extendObjects;
              data[0].set("user_item_xl_name", datas.name);
              data[0].set("user_item_xl", resWzxlData.phid_resbs);
              data[0].set("user_item_zl_name", datas.fname);
              data[0].set("user_item_zl", datas.f_phid);
              data[0].set("user_item_dl_name", datas.gname);
              data[0].set("user_item_dl", datas.g_phid);
            });
          } else {
            Ext.Msg.alert("未查询到该物资类型");
          }
        });
      });
  
    dstore.on("datachanged", async function (dstore, eOpts) {
      let PhidSenComp = mstform.getItem("PhidSenComp").getValue();
      let user_sjbm = mstform.getItem("user_sjbm").getValue();
      tarChange();
      dstore.each(function (record) {
        console.log(mstform.getItem("PhidSenComp").getValue(), "PhidSenComp");
        console.log(mstform.getItem("user_sjbm").getValue(), "user_sjbm");
        record.set("user_yhsyl",record.get("Qty"))
        async function asfun() {
          try {
            const res1 = await new Promise((resolve, reject) => {
              execServer("autoSelectType", { id: record.data.PhidItemId }, function (res) {
                resolve(res);
              });
            });
            const resWzxlData = JSON.parse(res1.data)[0].extendObjects;
            const res2 = await new Promise((resolve, reject) => {
              execServer("getAutoType", { phid: resWzxlData.phid_resbs }, function (res) {
                resolve(res);
              });
            });
            const datas = JSON.parse(res2.data)[0].extendObjects;
  
            record.set("user_item_xl_name", datas.name);
            record.set("user_item_xl", resWzxlData.phid_resbs);
            record.set("user_item_zl_name", datas.fname);
            record.set("user_item_zl", datas.f_phid);
            record.set("user_item_dl_name", datas.gname);
            record.set("user_item_dl", datas.g_phid);
            if (!record.data.PhidItemData) return; //判断是否为空
            execServer("GETitemzq", { phid: record.data.PhidItemData }, function (res) {
              try {
                const datas = JSON.parse(res.data);
                let DHZQ = datas[0].extendObjects.pur_lead;
                const newDate = addDaysToDate(mstform.getItem("BillDt").value, DHZQ);
                record.set("user_delivery_cycle", DHZQ);
                record.set("user_exp_arrival_date", newDate);
              } catch (error) {
                Ext.Msg.alert("服务器错误，请联系管理员");
              }
            });
          } catch (error) {
            console.error(error);
          }
        }
        if (!record.data.PhidItemId) return;
        record.set("ItemName", record.data.PhidItemId_EXName);
        record.set("ItemNo", record.data.ItemDataNo);
        if (PhidSenComp && user_sjbm && record.data.PhidItemId) {
          getBeforePrice(record);
        }
  
        asfun();
      });
      SetTotal();
    });
  
    function getBeforePrice(record) {
      let PhidSenComp = mstform.getItem("PhidSenComp").getValue();
      let user_sjbm = mstform.getItem("user_sjbm").getValue();
      execServer("getBeforePrice", { comphid: PhidSenComp, sjbm: `'${user_sjbm}'`, itemphid: record.data.PhidItemId }, function (res) {
        if (!(res?.count > 0)) return;
        try {
          const parsedData = JSON.parse(res.data || "[]")[0]?.extendObjects;
          if (!parsedData) return;
  
          record.set("PrcVatFc", parsedData.hsprc ?? record.get("PrcVatFc"));
          record.set("TaxRate", parsedData.taxrate ?? record.get("TaxRate"));
          record.set("PrcFc", parsedData.wsprc ?? record.get("PrcFc"));
        } catch (error) {
          console.log("getBeforePrice 解析错误", error);
        }
      });
    }
  
    function SetTotal() {
      var total = 0; //金额
      // 遍历 dstore 中的每个项
      dstore.each(function (item) {
        // 转换为数字
  
        let PlanPrc = Ext.Number.from(item.get("PlanPrc"), 0);
        let PrcFc = Ext.Number.from(item.get("PrcFc"), 0);
        let Qty = Ext.Number.from(item.get("Qty"), 0);
        if (!PlanPrc || !PrcFc || !Qty) return;
        total += (PlanPrc - PrcFc) * Qty;
      });
      console.log(total, "111111111111111111111111111111111111111111111111????????????????????");
      mstform.getItem("user_jcb_amt").setValue(total);
    }
    function addContractTerms(params) {
      console.log("addContractTerms");
      tabPanel.setActiveTab(2);
      var dgrid3 = Ext.getCmp("cntitemtab").items.items[0].items.items[0];
      if (dgrid3) {
        console.log(dgrid3, "dgrid3");
        // var GridID = Ext.getElementById(Ext.getElementById(Ext.getElementById(Ext.getElementById(Ext.getElementById(Ext.getElementById("cntitemtab-innerCt").children[0].id).children[0].id).children[0].id).children[0].id).children[2].id).children[0].id;
        // var grid1 = Ext.getCmp(GridID);
        let datas = [];
        datas.push(
          {
            NameNew: "预付款",
            PayType: "0",
            Remarks: "",
            PayProptyNew: "2",
            PayBaseTypeNew: "1",
            PhidItem: 8570000000000001,
            PhidItemNew: 8570000000000001,
          },
          // {
          // 	NameNew: "结算付款",
          // 	PayType: "1",
          // 	Remarks: "111",
          // 	PayProptyNew: "2",
          // 	PayBaseTypeNew: "1",
          // },
          // {
          // 	NameNew: "进度款",
          // 	PayType: "1",
          // 	Remarks: "111",
          // 	PayProptyNew: "2",
          // 	PayBaseTypeNew: "1",
          // },
          {
            NameNew: "设备到货",
            PayType: "1",
            Remarks: "",
            PayProptyNew: "2",
            PayBaseTypeNew: "1",
            PhidItem: 8570000000000008,
            PhidItemNew: 8570000000000008,
          },
          {
            NameNew: "安装调试款",
            PayType: "1",
            Remarks: "",
            PayProptyNew: "2",
            PayBaseTypeNew: "1",
            PhidItem: 8570000000000005,
            PhidItemNew: 8570000000000005,
          },
          {
            NameNew: "验收款",
            PayType: "1",
            Remarks: "",
            PayProptyNew: "2",
            PayBaseTypeNew: "1",
            PhidItem: 8570000000000004,
            PhidItemNew: 8570000000000004,
          },
          // {
          // 	NameNew: "审计款",
          // 	PayType: "1",
          // 	Remarks: "111",
          // 	PayProptyNew: "2",
          // 	PayBaseTypeNew: "1",
          // },
          {
            NameNew: "质保金",
            PayType: "1",
            Remarks: "",
            PayProptyNew: "2",
            PayBaseTypeNew: "1",
            PhidItem: 8570000000000007,
            PhidItemNew: 8570000000000007,
          }
  
          // {
          // 	NameNew: "安装完成",
          // 	PayType: "1",
          // 	Remarks: "111",
          // 	PayProptyNew: "2",
          // 	PayBaseTypeNew: "1",
          // },
          // {
          // 	NameNew: "调试完成",
          // 	PayType: "1",
          // 	Remarks: "111",
          // 	PayProptyNew: "2",
          // 	PayBaseTypeNew: "1",
          // }
        );
        dgrid3.store.add(datas);
      }
      tabPanel.setActiveTab(0);
    }
  }
  
  //计算结算信息中的逻辑
  
  //到货周期时间计算
  function addDaysToDate(dateString, daysToAdd) {
    // 将字符串解析为Date对象
    const date = new Date(dateString);
  
    // 检查是否有效日期ca
    if (isNaN(date)) {
      throw new Error("Invalid date string");
    }
    // 增加指定的天数
    date.setDate(date.getDate() + daysToAdd);
  
    return date;
  }
  